import request from '@/utils/request'
import { getToken } from '@/utils/auth'

var transformMethod = function(data) {
  let ret = ''
  for (const it in data) {
    ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
  }
  return ret
}

/**
 * 查询完工项配置数据列表
 */
export function getCompletionPageList(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/partner/completion/getCompletionPageList',
    method: 'get',
    params: query
  })
}

/**
 * 查询完工项目配置
 */
export function getCompletion(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/partner/completion/getCompletion',
    method: 'get',
    params: query
  })
}

/**
 * 删除完工项目配置
 */
export function removeCompletion(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/partner/completion/removeCompletion',
    method: 'get',
    params: query
  })
}

/**
 * 保存完工项目配置
 */
export function saveCompletion(params) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/partner/completion/saveCompletion',
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    transformRequest: [transformMethod],
    data: params
  })
}
